package com.zyy.command.demo01;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 命令调用者
 */
public class Waitor {
    //可以持有很多命令对象
    private List<Command> commandList;


    public Waitor() {
        commandList = new ArrayList<>();
    }

    public void addCommand(Command command) {
        commandList.add(command);
    }

    //发出命令 订单来了 大厨师开始执行命令
    public void orderUp() {
        System.out.println("来活了。。。");
        for (Command command : commandList) {
            if (command == null) {
                continue;
            }
            command.execute();
        }
    }
}
